package sort.test4_7;

public class BubbleSort {


    public int[] bubble(int[] nums) {
        if (nums.length == 0) {
            return null;
        }
        for (int i = 0; i < nums.length; i++) {
            for (int j = 1; j < nums.length - i; j++) {
                if (nums[j] < nums[j - 1]) {
                    int temp = nums[j];
                    nums[j] = nums[j - 1];
                    nums[j - 1] = temp;
                }
            }
        }
        return nums;
    }

    public static void main(String[] args) {
       BubbleSort bubbleSort = new BubbleSort();
        int[] a={2,51,3,4,9};
        int[] ints = bubbleSort.bubble(a);
        for (int b: ints
        ) {
            System.out.println(b);
        }
    }
}
